{% extends "base_step.html" %}
{% load i18n %}
{% load lp_extras %}
{% block content %}
{% if error_msg %}<div class="error_msg">{{ error_msg }}</div>{% endif %}
<table id="lptable">
<tr>
<td>{{ ulp.objtype }} {{ ulp.objname }}(x) =</td>
<td>
{% for i in ulp.obj_func %}
    <select name="obj_func_sign">
        {% ifequal i.0 "+" %}
            <option value="+" selected="selected">+</option>
            <option value="-">-</option>
        {% endifequal %}
        {% ifequal i.0 "-" %}
            <option value="+">+</option>
            <option value="-" selected="selected">-</option>
        {% endifequal %}
    </select>
    <input type="text" name="obj_func_val" value="{{ i.1 }}" size="{{ i.1|input_size:4 }}" maxlength="32" />
    x{{ forloop.counter }}
{% endfor %}
</td>
</tr>

<tr><td colspan="2">
</td></tr>

<tr>
<td></td>
<td>
{% for i in ulp.const_r %}
    {% for j in ulp.const_l|list_nest:forloop.counter0 %}
        <select name="const_l_sign">
            {% ifequal j.0 "+" %}
                <option value="+" selected="selected">+</option>
                <option value="-">-</option>
            {% endifequal %}
            {% ifequal j.0 "-" %}
                <option value="+">+</option>
                <option value="-" selected="selected">-</option>
            {% endifequal %}
        </select>
        <input type="text" name="const_l_val" value="{{ j.1 }}" size="{{ j.1|input_size:4 }}" maxlength="32" />
        x{{ forloop.counter }}
    {% endfor %}
    &nbsp;
    <select name="const_r_sign">
        {% ifequal i.0 "<=" %}
            <option value="<=" selected="selected">&le;</option>
            <option value="=">=</option>
            <option value=">=">&ge;</option>
        {% endifequal %}
        {% ifequal i.0 "=" %}
            <option value="<=">&le;</option>
            <option value="=" selected="selected">=</option>
            <option value=">=">&ge;</option>
        {% endifequal %}
        {% ifequal i.0 ">=" %}
            <option value="<=">&le;</option>
            <option value="=">=</option>
            <option value=">=" selected="selected">&ge;</option>
        {% endifequal %}
    </select>
    <input type="text" name="const_r_val" value="{{ i.1 }}" size="{{ i.1|input_size:5 }}" maxlength="32" />
    <br />
{% endfor %}
</td>
</tr>

<tr><td colspan="2">
</td></tr>

<tr><td></td><td>
{% if ulp.nonzero %}x<span class="index">i</span> &ge; 0 (i = 1 ... {{ n }})<br />{% endif %}
{% if ulp.binary %}x<span class="index">i</span> &isin; {0, 1} (i = 1 ... {{ n }})<br />{% endif %}
{% if ulp.integer %}x &isin; N<br />{% endif %}
</td></tr>
</table>

<div class="buttons">
<input type="button" value="{% trans "Back" %}" onClick="window.location.replace('{% url lp.lpx.views.step1 project.id %}');" />
<input type="submit" name="submit_action" value="{% trans "Next" %}" />
</div>

<script type="text/javascript">
var NumIn = document.getElementsByTagName("input");

function blurzero() {
    if (this.value == '') {
        this.value = '0';
    }
}
function focuszero() {
    if (this.value == '0') {
        this.value = '';
    }
}
function dynsize(e) {
    if (this.value.length > this.size && this.size < 32) {
	    this.size++;
    }
    if (this.value.length < this.size && this.size > 4 && this.size < 32) {
	    this.size--;
    }
}

for (var i=0; i < NumIn.length; i++) {
    NumIn[i].onfocus = focuszero;
    NumIn[i].onblur = blurzero;
    NumIn[i].onkeyup = dynsize;
    NumIn[i].onkeydown = dynsize;
    NumIn[i].onkeypress = dynsize;
    NumIn[i].onchange = dynsize;
}
</script>

{% endblock content %}
